<template>
  <div>
    父组件C
    <el-divider></el-divider>
    <my-a v-if="visible" :visible.sync="visible"></my-a>
    <el-button type="primary" size="small" @click="start">对话框</el-button>
    <el-divider></el-divider>
    <my-b :myObj="obj" @doSomething="fun1"></my-b>
  </div>
</template>
<script>
import A from './A'
import B from './B'

export default {
  name: 'C',
  components: {
    'my-a': A,
    'my-b': B,
  },
  data() {
    return {
      msg: 'this is a book ',
      obj: {name: 'jack', age: 20},
      arr: [10, 15, 20],
      visible: false,
    }
  },
  provide() {
    return {
      info: this.obj
    }
  },
  methods: {
    fun1(data) {
      console.log('子组件传来的数据是:', data)
    },
    start() {
      this.visible = true
    }
  }
}
</script>
